<template>
    <!-- 病例管理-报告意见单 -->
    <div class="check-table">
        <yx-table :is-fit="false" :table-data="tableData" :columns="columns" :page-obj="pageObj" :loading="loading" :tableHeightDefault="600">
            <template slot="patientSex" slot-scope="scope">
                <div>{{scope.scope.patientSex | sexFilter}}</div>
            </template>
            <template slot="isInvalidation" slot-scope="scope">
                <div>{{scope.scope.isInvalidation === "0" ? "否" : "是"}}</div>
            </template>
            <template slot="operate" slot-scope="scope">
                <div class="operate-btn">
                    <div>
                        <el-button style="color: #006DB8;" size="small" type="text" @click="preview(scope.scope)">
                            查看
                        </el-button>
                    </div>
                </div>
            </template>
        </yx-table>

        <pdf-dialog ref="pdfDialog"></pdf-dialog>
    </div>
</template>

<script>
    import yxTable from '@/components/yxtable/yx-table'
    import pdfDialog from '@/components/chatroom/view-pdf';
    export default {
        components: {
            yxTable,
            pdfDialog
        },
        props: {
            queryList: {
                type: Object,
                default () {
                    return {}
                }
            },
        },
        data() {
            return {
                columns: [
                    { label: '问诊患者', prop: 'patientName' },
                    { label: '性别', slot: 'patientSex' },
                    { label: '联系电话', prop: 'patientPhone' },
                    { label: '指导医生', prop: 'trueName' },
                    { label: '问诊日期', prop: 'acceptsTime' },
                    { label: '诊断', prop: 'diagnosisDescribe' },
                    { label: '项目', prop: 'checkProject' },
                    { label: '处理意见', prop: 'processingOpinion' },
                    { label: '操作', slot: 'operate' },
                ], // 操作列
                loading: false,
                pageObj: {
                    size: 10,
                    total: 0,
                    currentPage: 1,
                    func: (currentPage) => {
                        this.pageTurning(currentPage)
                    },
                    handleSizeChange: (size) => {
                        this.sizeChange(size)
                    }
                },
                tableData: [],
            }
        },
        mounted() {
            this.getInquiryInspectionOpinionList();
        },
        methods: {
            preview(e) {
                let params = {
                    id: e.id,
                    resource: 3
                };

                this.$refs.pdfDialog && this.$refs.pdfDialog.onOpen(params);
            },
            // 数据查询
            queryData() {
                this.getInquiryInspectionOpinionList();
            },
            pageTurning(currentPage) {
                this.pageObj.currentPage = currentPage;
                this.getInquiryInspectionOpinionList();
            },
            sizeChange(size) {
                this.pageObj.size = size;
                this.getInquiryInspectionOpinionList();
            },
            getInquiryInspectionOpinionList() {
                this.loading = true;
                let params = {
                    current: this.pageObj.currentPage,
                    size: this.pageObj.size,
                    endDate: this.queryList.time[1] || '',
                    startDate: this.queryList.time[0] || '',
                    patientName: this.queryList.patientName,
                    patientPhone: this.queryList.patientPhone
                }
                let apiName = this.$authInfo.getAuthType() == 'D' ? 'getInquiryInspectionOpinionList' : 'getPatientInspectionList';
                this.$ajax[apiName](params).then(res => {
                    this.loading = false;
                    let { code, data } = res;
                    if (code === 1) {
                        this.tableData = data.list
                        this.pageObj.total = data.total
                    }
                }).catch(err => {
                    this.loading = false;
                });
            }
        }
    }
</script>

<style lang="scss">
    .check-table {
        /deep/ .el-button--small {
            padding: 5px 15px;
        }
    }
</style>